﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="InitPurDetailsReport.aspx.cs"
    Inherits="PSS.WebSite.ReportManage.PurchasingReport.InitPurDetailsReport" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>采购明细报表</title>
    <script src="../../lib/boot.js" type="text/javascript"></script>
</head>
<body>
    <div class="mini-toolbar" style="padding: 2px; border-bottom: 0;">
        <table>
            <tr>
                <td align="right">
                    单据日期：
                </td>
                <td style="width: 150px;" align="left">
                    <input id="DocDateFrom" style="width: 150px;" class="mini-datepicker" format="yyyy-MM-dd" />
                </td>
                <td align="right">
                    至：
                </td>
                <td style="width: 150px;" align="left">
                    <input id="DocDateEnd" style="width: 150px;" class="mini-datepicker" format="yyyy-MM-dd" />
                </td>
                <td style="width: 70px;">
                    <a class="mini-button" iconcls="icon-search" onclick="search()">查 询</a>
                </td>
                <td style="width: 70px;">
                    <a class="mini-button" iconcls="icon-reset" onclick="reset()">重 置</a>
                </td>
            </tr>
        </table>
    </div>
    <div class="mini-toolbar" style="padding: 2px; border-bottom: 0;">
        <table style="width: 100%;">
            <tr>
                <td style="width: 100%;">
                    <a class="mini-button" id="export" iconcls="icon-excel" onclick="exportexcel();"
                        plain="true">导出Excel</a> <span class="separator"></span><a class="mini-button" onclick="close()"
                            iconcls="icon-close" plain="true">关闭</a>
                </td>
            </tr>
        </table>
    </div>
    <div class="mini-fit">
        <div id="grid1" class="mini-datagrid" style="width: 100%; height: 100%;" idfield="InitPurId"
            sizelist="[10,20,50,100]" pagesize="20">
            <div property="columns">
                <div type="indexcolumn">
                </div>
                <div field="DocDate" width="90" headeralign="center" allowsort="true" dateformat="yyyy-MM-dd">
                    单据日期
                </div>
                <div field="DocNumber" width="110" headeralign="center" allowsort="true">
                    单据编号
                </div>
                <div field="BusinessCategory" width="80" headeralign="center" allowsort="true" renderer="onBusinessCategoryRenderer">
                    业务类别
                </div>
                <div field="VendorCode" width="100" headeralign="center" allowsort="true">
                    供应商编号
                </div>
                <div field="VendorName" width="120" headeralign="center" allowsort="true">
                    供应商名称
                </div>
                <div field="GoodsCode" width="120" headeralign="center" allowsort="true">
                    商品编号
                </div>
                <div field="GoodsName" width="120" headeralign="center" allowsort="true">
                    商品名称
                </div>
                <div field="Specific" width="100" headeralign="center" allowsort="true">
                    规格型号
                </div>
                <div field="UnitName" width="60" headeralign="center" allowsort="true">
                    单位
                </div>
                <div field="StorageName" width="70" headeralign="center" allowsort="true">
                    仓库
                </div>
                <div field="Qty" width="100" headeralign="center" allowsort="true">
                    数量
                </div>
                <div field="PurchasePrice" width="100" headeralign="center" allowsort="true">
                    单价
                </div>
                <div field="PurchaseAmount" width="100" headeralign="center" allowsort="true">
                    采购金额
                </div>
            </div>
        </div>
    </div>
    <iframe id="exportIFrame" style="display: none;"></iframe>
    <script type="text/javascript">
        mini.parse();
        var now = new Date();
        var nowYear = now.getFullYear();
        var nowMonth = now.getMonth();
        var docDateFrom = mini.get("DocDateFrom");
        docDateFrom.setValue(new Date(nowYear, nowMonth, 1));
        var docDateEnd = mini.get("DocDateEnd");
        docDateEnd.setValue(new Date());
        var grid = mini.get("grid1");
        function search(e) {
            var DocDateFrom = docDateFrom.getFormValue();
            var DocDateEnd = docDateEnd.getFormValue();
            grid.setUrl("../../Service/ReportManageHandler.ashx?action=GetInitPurDetailsReportList");
            grid.load({ DocDateFrom: DocDateFrom, DocDateEnd: DocDateEnd });
        }
        function onKeyEnter(e) {
            search();
        }
        function reset(e) {
            docDateFrom.setValue(new Date(nowYear, nowMonth, 1));
            docDateEnd.setValue(new Date());
        }
        function onBusinessCategoryRenderer(e) {
            if (e.value == "2") { return "<span style=\"color: Red;\">退货</span>"; }
            else if (e.value == "1") { return "<span style=\"color: green;\">购货</span>"; }
        }
        function exportexcel() {
            var DocDateFrom = docDateFrom.getFormValue();
            var DocDateEnd = docDateEnd.getFormValue();
            var url = "../../Service/ReportManageHandler.ashx?action=ExportInitPurDetailsReport&DocDateFrom=" + DocDateFrom + "&DocDateEnd=" + DocDateEnd;
            var exportIFrame = document.getElementById("exportIFrame");
            exportIFrame.src = url;
        }
        function CloseWindow(action) {
            if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
            else window.close();
        }
        function close() {
            CloseWindow("close");
        }
    </script>
</body>
</html>
